package com.graduation.dairy.service;

import com.graduation.dairy.dao.UserRepository;
import com.graduation.dairy.entity.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService {
    private static final Logger log = LoggerFactory.getLogger(UserService.class);
    @Autowired
    private UserRepository userRepository;

    public boolean register(String email, String password) {
        if (userRepository.findByEmail(email) == null) {
            User newUser = new User();
            newUser.setEmail(email);
            newUser.setPassword(password);
            userRepository.save(newUser);
            return true;
        }
        log.info("test");
        return false;
    }

    public boolean login(String email, String password) {
        return true;
    }
}
